package com.masterclient.app.modules.goods;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.masterclient.app.R;
import com.eoner.baselibrary.utils.ScreenUtils;

/**
 * 作者：sean
 * 创建时间：2017/9/5 10:18
 * 功能说明：
 */

public class ActivityDialog extends Dialog{


    private Context mContext;
    private String title;
    private BaseAdapter adapter;
    public ActivityDialog(@NonNull Context context, String title, BaseAdapter adapter) {
        super(context,R.style.MyDialog);
        mContext = context;
        this.title = title;
        this.adapter = adapter;
    }

    private TextView tvTitle;
    private ImageView ivCancle;
    private ListView listView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_acticity);
        setCanceledOnTouchOutside(true);
        tvTitle = findViewById(R.id.tv_title);
        ivCancle =  findViewById(R.id.iv_cancel);
        listView = findViewById(R.id.listView);
        ivCancle.setOnClickListener(view -> dismiss());
        tvTitle.setText(title);
        listView.setAdapter(adapter);

    }

    @Override
    protected void onStart() {
        super.onStart();
        Window window = getWindow();
        window.setWindowAnimations(R.style.bottomShow);
        WindowManager.LayoutParams windowparams = window.getAttributes();
        window.setGravity(Gravity.BOTTOM);
        windowparams.height = (int) (ScreenUtils.getScreenHeight()*0.58);
        windowparams.width = ScreenUtils.getScreenWidth();
        window.setBackgroundDrawableResource(android.R.color.transparent);
        window.setAttributes(windowparams);
    }
}
